using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ChangeHeadPic : MonoBehaviour {
	
	public enum RightOrLeft{
		Right = 1,
		Left = -1,
	}
	
	public RightOrLeft rightOrLeft = RightOrLeft.Right;
	
	public UISprite headPicSprite;
	
	List<UIAtlas.Sprite> sprites = new List<UIAtlas.Sprite>();
	List<string> maleNames = new List<string>();
	List<string> femaleNames = new List<string>();
	int index;
	
	// Use this for initialization
	void Start () {
		index = 0;
		
		sprites = headPicSprite.atlas.spriteList;
		
		for(int i = 0;i < sprites.Count;i++){
			if(sprites[i].name.StartsWith("male")){
				maleNames.Add(sprites[i].name);
			} else {
				femaleNames.Add(sprites[i].name);
			}
		}
		
		CreateRoleInfo.GetInstance().HeadPicName = headPicSprite.spriteName;
	}
	
	void OnClick(){
		if(headPicSprite.spriteName.StartsWith("male")){
			headPicSprite.spriteName = maleNames[index];
			index ++;
			if(index > maleNames.Count - 1)
				index = 0;
		} else {
			headPicSprite.spriteName = femaleNames[index];
			index ++;
			if(index > femaleNames.Count - 1)
				index = 0;
		}
		
		CreateRoleInfo.GetInstance().HeadPicName = headPicSprite.spriteName;
	}
}
